//
//  Patch.hpp
//  markerARLib
//
//  Created by CADCG on 16/4/26.
//  Copyright © 2016年 CvidKal. All rights reserved.
//

#ifndef Patch_h
#define Patch_h

#include <opencv2/opencv.hpp>
namespace markerAR
{
    
class Patch
{

  typedef struct {float gx,gy;} G_xy;

  uchar **value;
  G_xy **gradient_;

public:

 Patch(int PatchSize_);
    ~Patch();
    Patch(const unsigned char* center,const unsigned int stride,int PatchSize_ = 9);
    int PatchSize;
    int halfPatch;
//  Patch<uchar,PatchSize>(const Patch<uchar,PatchSize>&& a)
//  {
//    this->gradient_ = a.gradient_;
//    a.gradient_ = NULL;
//    this->value = a.value;
//    a.value = NULL;
//    this->mean = a.mean;
//  }
//  
  
Patch(const Patch&a)=delete;

Patch& operator=(const Patch&a) = delete;
//  
//  Patch<uchar,PatchSize>& operator=(const Patch<uchar,PatchSize>&a)
//  {
//    if(this!=&a)
//    {
//      memcpy(this->value,a.value,sizeof(uchar)*PatchSize*PatchSize);
//      memcpy(this->gradient_,a.gradient_,sizeof(G_xy)*PatchSize*PatchSize);
//      this->patchImg = a.patchImg.clone();
//      this->mean = a.mean;
//    }
//    return *this;
//    
//  }
//  
  inline uchar val(const int x,const int y)const
  {
    assert(abs(x)<=halfPatch&&abs(y)<=halfPatch);
    return value[y+halfPatch][x+halfPatch];
  }
  inline G_xy gradient(const int x,const int y)const
  {
    assert(abs(x)<=halfPatch&&abs(y)<=halfPatch);
    return gradient_[y+halfPatch][x+halfPatch];;
  }
  int mean;
  cv::Mat patchImg;
};

}

#endif /* Patch_h */
